Skip to main content

Powershell script example

settings.json that accompanies script sample. Script runs as powershell -ExecutionPolicy Bypass -file copy.ps1 Note: Windows 10 ships with Powershell 5.1 which is not the latest version. Microsoft currently promotes Powershell 7 which can run side by side with Powershell 7. More info at Microsoft. After installing Powershell 7, use pwsh.exe as the runtime.

settings.json
{
"name": "Powershell script example.",
"dev_id": "efi.jobflow",
"description": "This is sample Connect package using Windows Powershell",
"script": "copy.ps1",
"email": "[email protected]",
"url": "http://efi.com/fieryjobflow",
"params": {
"RUNTIME": "powershell.exe",
"OPTION": "-ExecutionPolicy Bypass -file"
}
}
copy.ps1
write-host "script name: $($myInvocation.Path)"
write-host "number of arguments: $($args.count)"
write-host "arguments: $($args)"

$source = $args[0]
$target = $args[1]

write-host "source: $($source)"
write-host "target: $($target)"

Copy-Item -Path $source -Destination $target
if(Test-Path -Path $target) {
write-host "File copied"
}else {
write-host "File not copied"
}